import { createUUId } from '@/utils'
import { defineStore } from 'pinia'
import type { ISkuItem, IAttrItem } from './types'

export const useSkusStore = defineStore({
  id: 'skus',
  state: () => ({
    skus: [] as ISkuItem[],
    attrs: [] as IAttrItem[]
  }),
  actions: {
    // 批量新增入库 sku
    stockIn(list: ISkuItem[]) {
      this.skus = list.map((item) => {
        item.skuId = createUUId()
        return item;
      })
    },
    // 新增属性
    createSkuAttrs(list: IAttrItem[]) {
      this.attrs = list
    }
  },
})
